perm filename BILFM.PUB[PUB,MUS] blob sn#316412 filedate 1977-11-08 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00003 00002	.DEVICE XGP
C00004 00003	!group skip 2
C00049 ENDMK
C⊗;
.DEVICE XGP
.SPACING 10*5 MILLS;
.FONT 1 "BASL30"
.FONT 2 "FIX20"
.FONT 3 "BASB30"
.FONT 4 "BDR40"
.FONT 5 "FIX25"
.FONT 6 "BDI25"
.FONT 7 "MATH30"
.FONT 8 "SUB"
.FONT 9 "GRK30"

.AT "↓[" txt "]" ⊂"≡8txt≡*"⊃
.TURN ON "≡" FOR "%";
.PAGE FRAME 44 HIGH 78 WIDE
.TITLE AREA HEADING LINES 1 TO 2
.AREA TEXT LINES 3 TO 44
.PLACE HEADING
.SELECT 1
.PLACE TEXT
.NOJUST
.NOFILL
.SELECT 1
.EVERY HEADING(,{PAGE},);
.PAGE←0;
.NEXT PAGE
.COMMAND CHARACTER "!";

!group skip 2
!begin center
≡4The Simulation of Natural Instrument Tones
Using Frequency Modulation with a
Complex Modulating Wave
!group skip 1
≡3by Bill Schottstaedt
!end

!begin fill adjust
≡3 The frequency modulation  technique of  producing complex  audio
spectra can be extended in several  useful ways. In the  basic  case
(Chowning, 1973), the carrier wave  is modulated by one modulating  wave
where both waves are  simple sinusoids and both  are in the audio  band.
The modulated carrier then  becomes the audio  signal.  By changing  the
modulation index  and  the  carrier frequency  to  modulating  frequency
ratio, one can easily create many complex audio spectra.

Certain timbres, however,  seem to  be elusive.   Over the  last
several years at the Stanford Center for Computer Research in Music  and
Acoustics we  have been  doing extensive  work with  complex  modulating
waves. We have  found this process  to be  most
useful in the simulation  of string and piano  tones. The simulations    
described below use  a complex  modulating
wave made  up of  two or three sinusoidal  components, each  of whose  modulation
indices is  pitch dependent.  Separate  modulating oscillators  are
used to allow one to control the modulation indices independently,  thus
giving one more precise control over the spectra produced.  An  analysis
of actual piano and string tones served as the basis for the choice of the  indices
and of the carrier to modulating frequency ratios.
!GROUP SKIP 1
≡4Frequency Modulation with a Complex Modulating Wave
!GROUP SKIP 1
≡3When   a  wave   is  frequency   modulated
simultaneously by two modulating frequencies, side bands are created  at
all frequencies of the form:
!end

≡3   	     f↓[c]≡7 +≡3 mf↓[m1]≡7 + ≡3nf↓[m2] 

!begin fill adjust
≡3where m  and  n  are  integers,  and f↓[m1]  and  f↓[m2]  are  the  modulating
frequencies.  It is as if each of the side bands produced by one of  the
modulating signals were modulated as  a carrier by the other  modulating
signal. The equation of the resultant wave is
!end

            e =  A sin (≡9w≡3↓[c] +≡3 I↓[1]≡3 sin ≡9w≡3↓[1]≡3t +  I↓[2]≡3 sin ≡9w≡3↓[2]≡3t) 

!begin fill adjust
≡3where e is the instantaneous amplitude, A is the carrier amplitude, ≡9w≡3↓[c] ≡3is
2πf↓[c]≡3 and so on.         
	
	The amplitude of the side band  f↓[c]≡7 +≡3 mf↓[m1] ≡7+≡3 nf↓[m2]≡3 is
!end

	   J↓[m]≡3(I↓[1]≡3) * J↓[n]≡3(I↓[2]≡3)

!begin fill adjust
where I↓[1]≡3 and I↓[2]≡3  are the respective modulating  indices of f↓[m1] ≡3and  f↓[m2]≡3,
and J is the Bessel function of  the first kind and nth (or mth)  order.
Thus, the carrier amplitude is J↓[0]≡3(I↓[1]≡3) * J↓[0]≡3(I↓[2]≡3), and so on. 

!group skip 1
≡3An instrument making use of a complex modulating wave
with independently controllable indices on the components of that wave
could be diagrammed as follows:
!end
!begin nofill nojust
≡2
!group skip 2                  
                                         2*I↓[2]*f↓[c]
                          I↓[1]*f↓[c]   f↓[c]         |    f↓[c]*2
                            |      |         |      |
                           **********       **********
                           *   F1   *       *   F1   *
                            *      *         *      *
                             ******           ******
             Amplitude         |                |
                 |    f↓[c]       |                |
                 |      |______|________________|
                 |      |+      +
                **********
                *   F1   *
                 *      *
                  ******
                    |
                    ↓


!end
!begin fill adjust
≡3In this case F1 is a sine or cosine wave, and the mf/cf ratios are 1:1 and 2:1.
!group skip 1
By modulating the modulating wave one can create a modulating
wave with (theoretically) an infinite number of sinusoidal components. The
instantaneous ampliude (e) would then be given by the following formula:
!group skip 1
	e = A sin (≡9w≡3↓[c]≡3 + I↓[1] sin (≡9w≡3↓[1]≡3t + I↓[2] sin ≡9w≡3↓[2]≡3t))
!group skip 1
Here I↓[2] determines the number of significant components in the
modulating signal, and I↓[1] determines the number of significant components in the
output signal.
The ratio ≡9w≡3↓[1]≡3/≡9w≡3↓[c] determines the placement of the carrier's sidebands,
each of which has sidebands of its own at intervals determined by
≡9w≡3↓[2]≡3/≡9w≡3↓[1]≡3. Each sideband is both modulated and modulator, and the 
resulting mathematics is rather complicated.
≡3An instrument using a modulated modulating wave could be diagrammed as:
!end
!begin nofill nojust
!group skip 2
≡2
                                          I↓[2]*f↓[c]    f↓[c]
                                             |      |
                                            **********
                                            *   F1   *
                                             *      *
                                              ******
                                I↓[1]*f↓[c]           |
                                     |     f↓[c]   |
                                     |      |___|
                                     |      |+
                                    **********
                                    *   F1   *
                                     *      *
                                      ******
                                         |
        Amplitude    f↓[c]                  |
               |      |__________________|
               |      |+
              **********
              *   F1   *
               *      *
                ******
                   |
                   ↓
!group skip 1
!end
!begin fill adjust
≡4A Piano Simulation
!group skip 1
≡3The frequency modulation piano is not much more complicated 
than the first of the instruments diagrammed above.
The simulation of piano tones uses a modulating wave made up of two sinusoidal
components, one at (basically) the carrier frequency and one at four times
the carrier frequency. By using two modulating oscillators (one for each
component), the amplitude of each component can be handled independently.
These amplitudes (the indices) are made frequency dependent
according to the following formulae:
!end
!group skip 1
!begin nofill nojust
1:1 mf/cf Index = 15 * (8 - log↓[e](f↓[c]) ) / (log↓[e](f↓[c]) * log↓[e](f↓[c]) )
4:1 mf/cf Index = 20 * (8 - log↓[e](f↓[c]) ) / f↓[c]
!end
!group skip 1
!begin fill adjust
These formulae produce a spectrum that  is rich and complex  in
the lower register, but gets steadily  simpler as the pitch rises.     
The resulting evolution of the spectrum gives a good piano  simulation
over its entire range, and avoids foldover.                     
!group skip 1
≡3The component frequencies of the modulating wave are 
slightly  larger than integral  multiples of the  carrier
frequency. A small constant of about .5% of the carrier frequency is added to
the modulating frequencies to simulate the characteristic "stretched" or sharp
harmonics of the piano. The resulting
inharmonicity is less than that of a real piano (Young, 1954), but larger
values created noticeable beats. A truly harmonic spectrum produced inescapably
the timbre of an electric piano. Thus, for the piano simulation,
!group skip 1
e = A sin (2π f↓[c]t + I↓[1] sin 2π (f↓[m1] + S ) t + I↓[2] sin 2π (f↓[m2] + S ) t)
!group skip 1
!end
!begin nofill nojust
where f↓[c] : f↓[m1] : f↓[m2] = 1 : 1 : 4,
S = f↓[c] / 200,
with I↓[1] and I↓[2] as given above.
!end
!begin fill adjust
!group skip 1
If equal-tempered tuning is employed throughout
the inharmonicity  of  the resultant partials seems  to
fool the ear into thinking that the bass notes are sharp and the  treble notes flat.
A slight retuning was employed in some of the synthesized pianos, along the lines
of actual piano tunings, by placing in the I_ONLY block the following statements:
!end
!begin nofill nojust

	IF f↓[c] < F / 2 THEN f↓[c] ← f↓[c] - ( 10 / f↓[c] )
	IF f↓[c] > F * 2 THEN f↓[c] ← f↓[c] + ( f↓[c] / 200 )

!end
!begin fill adjust
Statements in the I_ONLY block ("Initialization Only") are evaluated only when
the instrument is initialized (called by the play file). F / 2 is the F a fifth
below middle c, F * 2 is the f an eleventh above middle c.
!group skip 1
Another characteristic of piano tones is that the decay time  of
a given note is dependent on the pitch and amplitude of that note.
The lower the frequency, or the greater the volume (determined, of course
by how hard the key is struck), the longer the note takes to decay,
if the damper is kept up. "A" in the formula given above is therefore
a function of the undamped decay characteristics of a given note which is 
interrupted by the fall of the damper.
This can be simulated with two unit generators controlling the note's 
amplitude -- one as the damper (its envelope time set in the play file)
and the other as the fixed exponential decay (its envelope time dependent
only upon the note's frequency and amplitude).

The decay function used is  not  truly  exponential.  It  was  found  that  an
exponential amplitude envelope could  give either a  good attack to  the
note or a  good "ring",  but not  both.  The  function used  here (see figure 1) has  a
rather sharp  attack followed  by a  long, slow  decay. 
Its decay time (which is independent of the note length is given by the following
formula:
!group skip 1
T = 10 ( ≡7\≡3A ) / ≡7\≡3f↓[c] 
!group skip 1
where A is the amplitude on a scale of 0 - 2000, f↓[c] is the fundamental
frequency, and T is the resulting fixed decay length of the amplitude
envelope.  This formula was obtained by determining the decay times of several
notes at several different amplitudes and fitting the results to a simple curve.
It, like the tuning formula given above, is only a working approximation
of an actaul piano's characteristics.  At middle c the decay time ranges
from 4 seconds for a very soft note to 25 seconds for a very loud one.
At an amplitude of 400 (rather loud) the decay time ranges from 40 seconds
in the extreme low register to 4 seconds at the highest c of the piano.
!group skip 1
The envelope generator containing the fixed decay envelope is then multiplied
by another envelope generator containing the damping envelope. (see figure 2)
Its value is one until the note is to be cut off, when it falls rapidly to zero.
!group skip 10

A better  simulation,  especially  in the  higher  register,  is
produced by using  two  added outputs to
mimic the  piano's use  of  several strings  for  each note.   They  are
slightly mistuned to give a simple chorus effect.  The amplitude of each
output is controlled by a scaler  which removes two of the "strings"
in the lower register -- again modelled after real pianos. 

Pedaling can be rather crudely simuated by overlapping the notes being
"pedalled" while increasing the amplitude of the reverberated signal.

It may  be of  some interest  that  there is  no need to change the
modulation indices over the  course of a note, or to  simulate
the various  noises  produced by  a  piano's action. 
!next page
	The following is a flow chart of an FM piano.
!end
!begin nofill nojust

≡2
                1  DecayLength
               	|      |
   EXPEN       **********      			
   "Decay"     *   F2   *                       Index1 * f↓[c]   f↓[c] + Stretch
                *      *                                   |      |      
                 ******                         OSCIL      |      | 
                   |                            "Mod1"    **********
                   |                                      *   F1   *
                   |                                       *      *      
                   |	                                    ******
                   |  4 * Index2 * f↓[c]                          |
                   |           |  4 * (f↓[c] + Stretch)           |
                   |           |     |                         |
OSCIL              |         **********                        |
"Damper"           |  OSCIL  *   F1   *                        |
                   |  "Mod2"  *      *                         |
Amplitude Duration |           ******                          |
     |      |      |              |                            |
    **********     |              |                            |
    *   F3   *     |              |                            |
     *      *      |              |                            |
      ******       |              |                            |
         |_________|              |                            |
                  *|     f↓[c]       |                            |
                   |      |_______|____________________________|
                   |      |+       +
      ZOSCIL      **********
      "Snd"       *   F1   *
                   *      *
                    ******
                      |
                      ↓
                     OUTA

!group skip 1      
≡3The functions are as follows:
F1 -- sinewave
F2 -- see figure 1
F3 -- see figure 2
!group skip 2
!end
!NEXT PAGE
!begin fill adjust
≡4String Simulation
!GROUP SKIP 1
≡3
String tones can also be synthesized using a complex modulating wave.
In the case of the violin, modulating frequency to carrier frequency ratios
of 1:1, 3:1, and 4:1 were found to be most convincing. Once again pitch
dependent index formulae were used. The following were found to work well:
!group skip 1
!end
!begin nofill nojust
1:1 mf/cf Index = 7.5 / log↓[e](f↓[c]) 
3:1 mf/cf Index = (8.5 - log↓[e](f↓[c]) ) / (3 + (f↓[c] / 1000) )
4:1 mf/cf Index = 1.25 / ≡7\≡3(f↓[c])           
or
3:1 mf/cf Index = 10 * (8.5 - log↓[e](f↓[c]) ) / f↓[c];
!end
!group skip 1
!begin fill adjust
These formulae can be multiplied by as much as two or three, to produce
a more strident timbre. Even higher indices will give a primitive sul ponticello
effect. Simpler formulae can also be used, and either the
second or third modulators can be dispensed with if necessary. Of course the
index formulae will have to be changed in the latter case.
The following, for example, works rather well in the cello range:
!end
!begin nofill nojust
!group skip 1
1:1 mf/cf Index = 7.5 / log↓[e](f↓[c])
3:1 mf/cf Index = 15 / ≡7\≡3(f↓[c])               
!end
!begin fill adjust
!group skip 1
To simulate the attack noise of a string instrument with its
frequency skew, chiff, and so forth, a random number generator is used
with a frequency of 2000 Hz and a bandwidth of 20% of the carrier frequency.
This, combined with sharply higher indices in the first .2 seconds of the
note gives an adequate simulation of the string attack. The index and noise
function is given in figure 3. Figure 4 shows the overall amplitude
function of the strings. The rise and decay times are fixed at .2 seconds.
The steady state then takes whatever time is left over.

One can simulate the decay of a detached note
by causing the indices to go to zero during the note's decay.
An overlap of about .2 seconds gives a good legato.
!group skip 1
An oscillator is used to create a five to six Hz vibrato and another random number
generator causes a random fluctuation in the vibrato (at a frequency of about
ten to twenty Hz). 
!end
!next page
!begin nofill nojust
The flow chart of the FM violin is as follows:
≡2
!group skip 1

                   Periodic     Random
  Amplitude        Vibrato      Vibrato               Attack Function
!group skip 1
    |  |            |    |      |      |                   |    |
   ******         **********   **********                **********
\ *  F4  */       *   F1   *   * RANDI  *                *   F5   *
 *        *        *      *    *        *                 *      *
************        ******     **********   Attack Noise   ******
     |                |             |           ______________|
     | LINEN      1___|             |____1      |             |
     |               +|             |+          |    |*       |
     |                |_____________|         **********      |
     |                             *|         * RANDI  *      |
     |                              |         *        *      |
     |                              |         **********      |
     |                              |              |          |
     |                              |              |___1      |
     |                              |              |+         |
     |                              |______________|          |
     |                              |*                        |
     |                              ↓                         ↓
     |                            Newmag                    Attack
     |
     |                 (Index2+Attack)*f↓[c]*3
     |                           |
     |      (Index1+Attack)*f↓[c]|   (Index3+Attack)*f↓[c]*4
     |              |            |            |
     |              |   Scfreq   |   Scfreq*3 |   Scfreq*4
     |              |      |     |      |     |      |
     |             **********   **********   **********
     |             *   F1   *   *   F1   *   *   F1   *
     |              *      *     *      *     *      *
     |               ******       ******       ******
     |                  |            |            |
     |  Amp   Scfreq    |            |            |
     |____|     |_______|____________|____________|
         *|     |+       +            +
        **********
        *   F1   *
         *      *
          ******
            |
            ↓

≡3Scfreq = f↓[c] * newmag.
The functions used are the following:
F1 -- sinewave.
F2 -- see figure 3
F3 -- see figure 4

!group skip 1
!end
!next page
!begin fill adjust
≡4Special Effects
!group skip 1
≡3	To produce pizzicato, replace the given amplitude function
with the decay function of the piano, decrease the decay time drastically,
decrease the indices and attack noise, and multiply the indices by the
decay function (causing them to go to zero as the amplitude does).
!group skip 1
        Swiches can be added in the instrument allowing one to
choose between either arco or pizzicato, vibrato or non vibrato, legato or detached,
and so on.
!group skip 1
	A convincing choral effect (the sound of an entire orchestral section)
can be simulated by adding a second output with its own modulators and vibrato
generators. One then adds to the various modulating frequencies a series of
small (unequal) constants equivalent to that added to the piano to get
the stretched harmonics. These constants should be between 1.5 and 4 Hz.
!group skip 1
≡4Conclusion
!group skip 1
≡3Many other instrument tones can be synthesized using a complex modulating wave,
including those of the various brass and percussion instruments.  The examples
given above should sufficiently illustrate the workings of a process whose potential
is only beginning to be explored. 
!GROUP SKIP 1
≡4Appendix
!group skip 1
≡3Given below are the MUSCMP instrument definitions
of the FM piano and violin.
!end
!begin nofill nojust
!group skip 1
≡2ARRAY DecayFunc, AmplitudeFunc, Sinewave(512);
SYNTH(Sinewave); 1,1 999;
SEG(AmplitudeFunc); 1,1 1,95 0,100;
SEG(DecayFunc);1,1 .6,5 .3,10 .15,25 .07,50 0,100;

INSTRUMENT PIANO;
VARIABLE Amplitude, DecayLength, Freq,              
	Duration, Stretch,Index1, Index2,                    
	/Decay, /Damper, /Modulator1, /Modulator2, /Snd;
I_ONLY BEGIN
    Duration ← P2;         			< Set in play file 
    Freq ← P3;   				< Set in play file 
    Amplitude ← P4;  			        < Set in play file
  						< ALOG gives the natural log
    Index1 ← 15 * (8 - ALOG(Freq)) / (ALOG(Freq) * ALOG(Freq));   
    Index2 ← 20 * (8 - ALOG(Freq)) / Freq;
    DecayLength ← 10 * SQRT(Amplitude) / SQRT(Freq);     
    Stretch  ←  Freq/200;  
END;  
Decay ← EXPEN(1, MAG / DecayLength, DecayFunc);  
Damper ← OSCIL(Amplitude, MAG / P2, AmplitudeFunc);
Modulator1 ← OSCIL (Freq * MAG * Index1, (Freq + Stretch) * MAG, Sinewave);	      
Modulator2 ← OSCIL (4 * Freq * MAG * Index2, 4 * (Freq + Stretch) * MAG, Sinewave);	      
Snd ← ZOSCIL (Decay * Damper, Freq * MAG + Modulator1 + Modulator2, Sinewave);	
OUTA ← OUTA + Snd;       
END;

!group skip 1
ARRAY Sinewave, AttackFunc, AmpFunc(512);
SEG(AttackFunc); 1,1 0,25 0,100;
SEG(AmpFunc);0,0 1,25 1,50 0,75 0,100;
SYNTH(Sinewave); 1,1 999;

INSTRUMENT VIOLIN;
VARIABLE Reset, Noise, /NewMag,	Freq, Amplitude, Duration, 
	AttackTime, DecayTime, Index1, Index2, Index3,
	/Modulator1, /Modulator2, /Modulator3, /Env, /Att, /Vibrato,
	/Flutter, /Snd;

I_ONLY BEGIN
    Duration ← P2;    <Set in play file
    Freq ← P3;        <Set in play file
    Amplitude ← P4;   <Set in play file

    DecayTime ← .7; 
    AttackTime ← .2; 
    Noise ← .1;         

    Index1 ← 7.5 / ALOG(Freq);   <ALOG gives the natural log
    Index2 ← 1.25 / SQRT(Freq);  <SQRT gives the square root
    Index3 ← (8.5 - (ALOG(Freq))) / (3 * (1 + Freq / 4000));

    IF AttackTime + DecayTime ≥ Duration
	THEN BEGIN
	    AttackTime ← Duration * AttackTime;
            DecayTime ← Duration * DecayTime;
            IF AttackTime≤.05 THEN AttackTime ← Duration - DecayTime - .01;
	END;
END;
Env ← LINEN (1, AttackTime, DecayTime, Duration, AmpFunc, Reset←0);	 
Flutter ← RANDI(.005, 10 * MAG);				
Vibrato ← OSCIL(Env * .005, 5 * MAG, Sinewave);		
Att ← EXPEN(1, MAG * 8, AttackFunc);

NewMag ← (1 + Flutter) * (1 + Vibrato) * (1 +
	RANDI (Noise *  Att, 2000 * MAG)) * MAG;                                

Modulator1 ← OSCIL (Freq * MAG * (Att + Index1), Freq * NewMag, Sinewave);	
Modulator2 ← OSCIL (4 * Freq * MAG * (Att + Index2), 4 * Freq * NewMag, Sinewave);
Modulator3 ← OSCIL (3 * Freq * MAG * (Att + Index3), 3 * Freq * NewMag, Sinewave); 
Snd ← ZOSCIL (Env * Amplitude, Freq * NewMag + Modulator1 + Modulator2 + Modulator3, Sinewave);	
OUTA ← OUTA + Snd;          
END;
!end
!group skip 2
!begin nofill nojust
≡3Acknowledgements: I  would like  to thank  John Chowning, Julius Smith,
	Robert  Poor, and  Robert  Harvey  for  their valuable assistance.

Bibliography:
1.  Chowning, John, "The Synthesis of Complex Audio Spectra by Means of
	Frequency Modulation", Journal of the Audio Engineering Society,
	21 (7), 1973  pp526-534.
2. Young, R. W.,"Inharmonicity of Piano Strings", Acustica, vol 4, 1954,
	pp259-262.
3. Grey, John, "Lexicon of Analyzed Tones (Part 1: A violin Tone)",
	Computer Music Journal, 2 (1), 1977 pp39-45.
!end